<template>
  <div class="type_container">
    <div v-for="(v,i) in categoryList"
         :key="i">
      <add-type-item :toCategory="categoryList[i]"
                     v-on:getCloseDialogByAddType="getCloseDialogByAddType"></add-type-item>
      <!-- {{categoryList[i].categoryName}} -->
    </div>
  </div>
</template>
<script>
import { getAllCategory } from "../../api/http.js";
export default {
  created () {
    this.getAllCategory()
  },
  data () {
    return {
      // categoryList: {
      //   categoryDetail: '',
      //   categoryId: 1,
      //   categoryImg: '',
      //   categoryName: '',
      //   path: ''
      // }
      categoryList: []
    }
  },
  methods: {
    // 获取所有分类信息
    async getAllCategory () {
      const { data: res } = await getAllCategory();
      console.log(res.data)
      this.categoryList = res.data
    },
    getCloseDialogByAddType (val) {
      console.log(val)
      this.$emit("closeDialog", val)
    }
  }
}
</script>
<style lang="less" scoped>
.type_container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  padding: 6px;
}
</style>